/*
 * User: dvetters
 * Date: 8/16/2010
 * Time: 2:01 PM
 * 
 * 
 */
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace Echium2
{
	/// <summary>
	/// Description of MediaSourceTreeView.
	/// </summary>
	public partial class MediaSourceTreeView : TreeView
	{
		public MediaSourceTreeView()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		public TreeNode AddItem(String name, ItemType type, int parentIdx)
		{
			int typeInt = -1;
			switch(type)
			{
				case ItemType.iPod:
					typeInt = 2;
					break;
				case ItemType.Library:
					typeInt = 0;
					break;
				case ItemType.Playlist:
					typeInt = 1;
					break;
				case ItemType.PlayQueue:
					typeInt = 1;
					break;
			}
			if (parentIdx == -1) //we're adding a new source
			{
				return this.Nodes.Add(name, name, typeInt, typeInt);
			}
			else
			{
				return this.Nodes[parentIdx].Nodes.Add(name, name, typeInt, typeInt);
			}
		}
		
		public int AddItem(TreeNode node, int parentIdx)
		{
			if (parentIdx == -1) //we're adding a new source
			{
				return this.Nodes.Add(node);
			}
			else
			{
				return this.Nodes[parentIdx].Nodes.Add(node);
			}
		}
	}
}
